package ar.edu.unq.mongodbexample.homes;

import java.util.List;

import ar.edu.unq.mongodbexample.model.Career;
import ar.edu.unq.mongodbexample.persistence.MongoDBManager;

import com.google.code.morphia.dao.BasicDAO;

public class CareerHome extends BasicDAO<Career, String> implements IHome<Career> {

	public CareerHome() {
        super(Career.class, MongoDBManager.getInstance().getDataStore());
        MongoDBManager.getInstance().getMorphia().map(Career.class);
    }
	
	public int saveAll(List<Career> entityList) {
		int notSaved = 0;
        for (Career career : entityList) {
            try {
                this.save(career);
            } catch (Exception e) {
                notSaved++;
            }
        }
        return notSaved;
	}

	public List<Career> getAll() {
		return this.ds.find(Career.class).asList();
	}

	public Career findById(Object id) {
		return this.ds.get(Career.class, id);
	}

}